﻿using DC2010.Objects.Base;
using DC2010.Objects;
using DC2010.Objects.Data;

namespace DC2010.Conditions
{
    public class C_IsItemInRightHand : ConditionLogic
    {
        public C_IsItemInRightHand(ConditionData cd)
            : base(cd)
        {
            ShortName = "Is item in right hand";
            LongName = "Checks if item is in right hand.";
        }

        public override bool CheckCondition(BaseObject aInvoker, BaseObject aTarget)
        {
            if ((aInvoker is CreatureData)&&(aTarget is ItemData))
            {
                CreatureData c = (CreatureData)aInvoker;
                ItemData i = (ItemData)aTarget;

                ItemData iii = c.L.Possession(CarryLocations.RightHand);

                if (iii != null)
                {
                    HandleEffects(iii.InfoId == i.Id, aInvoker, aTarget);
                    return iii.InfoId == i.Id;
                }

                HandleEffects(false, aInvoker, aTarget);
                return false;
            }

            return false;
        }
    }
}
